<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" xmlns:risk="">
<body class="hold-transition skin-blue sidebar-mini">
<style>
    .sTh {
        -webkit-line-clamp: 1;
    / / 限制显示的文本的行数为3 -webkit-box-orient: vertical;
    / / 水平排列 < p > ，使其不纵向显示 word-break: break-all;
    / / 使 < p > 中的文字换行 overflow: hidden;
    / / 超出的文字部分隐藏 text-overflow: ellipsis;
    / / 超出的文字部分用 . . . 来显示 display: -webkit-box;
    / / 将 < p > 变成高度定死，宽度自适应的行内块元素
    }
</style>
<div class="wrapper">
    <div th:replace="common::com">
    </div>
    <div th:replace="common:: left">
    </div>
    <div th:replace="common:: top">
    </div>
    <!-- Content Wrapper. Contains page content -->
    <div class="content-wrapper">
        <section class="content">
            <div class="row">
                <form action="/jobInfo/list" method="post">
                    <div class="col-xs-3">
                        <div class="input-group">
                            <span class="input-group-addon">状态:</span>
                            <select class="form-control" id="callStatus" name="callStatus">
                                <option value="">全部</option>
                                <option value="0" th:selected="${jobSearch.callStatus=='0'}">正常</option>
                                <option value="1" th:selected="${jobSearch.callStatus=='1'}">暂停</option>
                                <option value="2" th:selected="${jobSearch.callStatus=='2'}">删除</option>
                            </select>
                        </div>
                    </div>
                    <div class="col-xs-3">
                        <div class="input-group">
                            <span class="input-group-addon">组名:</span>
                            <input th:value="${jobSearch.jobGroup}" type="text" class="form-control" id="jobGroup"
                                   name="jobGroup" autocomplete="on">
                        </div>
                    </div>
                    <div class="col-xs-3">
                        <div class="input-group">
                            <span class="input-group-addon">任务名:</span>
                            <input type="text" th:value="${jobSearch.jobName}" class="form-control" id="jobName"
                                   name="jobName" autocomplete="on">
                        </div>
                    </div>
                    <div class="col-xs-1">
                        <button class="btn btn-block btn-info" id="searchBtn">查找</button>
                    </div>
                </form>
                <div risk:check="/jobInfo/saveJob" class="col-xs-2">
                    <button class="btn btn-block btn-success add" data-toggle="modal" data-target="#addModal">新增
                    </button>
                </div>
            </div>
            <div class="row">
                <div class="col-xs-12">
                    <div class="box">
                        <div class="box-body">
                            <table id="job_list" class="table table-bordered table-striped" width="100%">
                                <thead>
                                <tr>
                                    <th name="jobGroup">组名</th>
                                    <th name="jobName" width="10%">任务名</th>
                                    <th name="jobStatus">任务状态</th>
                                    <th name="jobDesc">任务描述</th>
                                    <th name="cornExoression">执行规则</th>
                                    <th name="systemName">所属系统</th>
                                    <th name="service">服务名</th>
                                    <th name="method">方法名</th>
                                    <th name="version">版本</th>
                                    <th name="version">任务依赖</th>
                                    <th name="alarmEmail">警告邮件</th>
                                    <th name="concurrentNum">并发数量</th>
                                    <th name="concurrentNum">运行数量</th>
                                    <th>参数</th>
                                    <th>操作</th>
                                </tr>
                                </thead>
                                <tbody>
                                <tr th:each="scheduleJob:${page.list}">
                                    <td th:text="${scheduleJob.jobGroup}" class="sTh"
                                        style="width:10%; word-break: break-all;"></td>
                                    <td th:text="${scheduleJob.jobName}" class="sTh"
                                        style="width:10%; word-break: break-all;"></td>
                                    <td>
                                        <span th:text="${scheduleJob.jobStatus=='0'?'正常':''}"></span>
                                        <span th:text="${scheduleJob.jobStatus=='1'?'暂停':''}"></span>
                                        <span th:text="${scheduleJob.jobStatus=='2'?'删除':''}"></span>
                                    </td>
                                    <td th:text="${scheduleJob.jobDesc}"></td>
                                    <td th:text="${scheduleJob.cronExpression}"></td>
                                    <td th:text="${scheduleJob.systemName}"></td>
                                    <td th:text="${scheduleJob.service}"></td>
                                    <td th:text="${scheduleJob.method}"></td>
                                    <td th:text="${scheduleJob.version}"></td>
                                    <td th:text="${scheduleJob.depend}" class="sTh"
                                        style="width:10%; word-break: break-all;"></td>
                                    <td th:text="${scheduleJob.alarmEmail}"></td>
                                    <td>
                                        <span th:if="${scheduleJob.concurrentNum==0}">-</span>
                                        <span th:if="${scheduleJob.concurrentNum>=1}"
                                              th:text="${scheduleJob.concurrentNum}"></span>
                                    </td>
                                    <td th:text="${scheduleJob.runNum}"></td>
                                    <td th:text="${scheduleJob.parameters}"></td>
                                    <td>
                                        <a risk:check="/jobInfo/executeJob" href="#"
                                           th:if="${scheduleJob.jobStatus!='2'}"
                                           th:onclick="'executeJob(\''+${scheduleJob.jobId}+'\')'">立即执行</a>
                                        <a risk:check="/jobInfo/pauseJob" href="#" th:if="${scheduleJob.jobStatus=='0'}"
                                           th:onclick="'pauseJob(\''+${scheduleJob.jobId}+'\')'">暂停</a>
                                        <a risk:check="/jobInfo/resumeJob" href="#"
                                           th:if="${scheduleJob.jobStatus=='1'}"
                                           th:onclick="'resumeJob(\''+${scheduleJob.jobId}+'\')'">启动</a>
                                        <a risk:check="/jobInfo/editJob" href="#" th:if="${scheduleJob.jobStatus!='2'}"
                                           th:onclick="'editJob(\''+${scheduleJob.jobId}+'\')'">编辑</a>
                                        <a risk:check="/jobInfo/deleteJob" href="#"
                                           th:if="${scheduleJob.jobStatus!='2'}"
                                           th:onclick="'deleteJob(\''+${scheduleJob.jobId}+'\')'">删除</a>
                                    </td>
                                </tr>
                                </tbody>
                            </table>
                            <div th:include="page::page" url="/jobInfo/list"></div>
                        </div>
                    </div>
                </div>
            </div>
        </section>
    </div>
</div>

<!-- job新增.模态框 -->
<div class="modal fade" id="addModal" tabindex="-1" role="dialog" aria-hidden="true">
    <div class="modal-dialog modal-lg">
        <div class="modal-content">
            <div class="modal-header">
                <h4 class="modal-title">新增任务</h4>
            </div>
            <div class="modal-body">
                <form class="form-horizontal form" role="form" id="addJobInfo" action="/jobInfo/saveJob"
                      onsubmit="return false;">
                    <div class="form-group">
                        <label class="col-sm-2 control-label">组名:<font
                                color="red">*</font></label>
                        <div class="col-sm-4">
                            <input type="text" class="form-control" name="jobGroup"
                                   placeholder="请输入组名"
                                   maxlength="32">
                        </div>
                        <label class="col-sm-2 control-label">任务名:<font
                                color="red">*</font></label>
                        <div class="col-sm-4"><input type="text" class="form-control" name="jobName"
                                                     placeholder="请输入任务名"
                                                     maxlength="32"></div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">任务状态:<font
                                color="red">*</font></label>
                        <div class="col-sm-4">
                            <select class="form-control" id="status" name="jobStatus">
                                <option value="0">正常</option>
                                <option value="1">暂停</option>
                                <option value="2">删除</option>
                            </select>
                        </div>
                        <label class="col-sm-2 control-label">触发规则:<font
                                color="red">*</font></label>
                        <div class="col-sm-4"><input type="text" class="form-control" name="cronExpression"
                                                     placeholder="请输入触发规则"
                                                     maxlength="32"></div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">系统名:<font
                                color="red">*</font></label>
                        <div class="col-sm-4">
                            <select class="form-control" id="systemName" name="systemName">
                                <option th:each="system:${systemList}" th:value="${system.systemName}"
                                        th:text="${system.systemName}"></option>
                            </select>
                        </div>
                        <label class="col-sm-2 control-label">任务描述 :</label>
                        <div class="col-sm-4"><input type="text" class="form-control" name="jobDesc"
                                                     placeholder="请输入任务描述"
                                                     maxlength="32"></div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">serviceName:<font
                                color="red">*</font></label>
                        <div class="col-sm-4"><input type="text" class="form-control" name="service"
                                                     placeholder="请输入service"
                                                     maxlength="64"></div>
                        <label class="col-sm-2 control-label">methodName :<font
                                color="red">*</font></label>
                        <div class="col-sm-4"><input type="text" class="form-control" name="method"
                                                     placeholder="请输入method"
                                                     maxlength="64"></div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">任务依赖:</label>
                        <div style="width:80%" class="col-sm-4"><input type="text" class="form-control" name="depend"
                                                                       placeholder="请输入依赖的任务(任务组名_任务名)"
                                                                       maxlength="250"></div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">警告邮件:</label>
                        <div style="width:80%" class="col-sm-4"><input type="text" class="form-control"
                                                                       name="alarmEmail"
                                                                       placeholder="请输入警告邮件(多个用逗号隔开)"
                                                                       maxlength="250"></div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">并发控制:<font
                                color="red">*</font></label>
                        <div class="col-sm-4">
                            <select class="form-control" id="concurrentNum" name="concurrentNum"
                                    onchange="selectNum(this)">
                                <option value="0">无限</option>
                                <option value="1">有限</option>
                            </select>

                        </div>
                        <div class="col-sm-4">
                            <input type="text" class="form-control" name="concurrentCount" id="concurrentCount"
                                   placeholder="请输入具体数量" style="display:none">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">定时任务类型:<font
                                color="red">*</font></label>
                        <div class="col-sm-4">
                            <select class="form-control" id="taskType" name="taskType" onchange="putPath(this)">
                                <option value="0">代码</option>
                                <option value="1">shell脚本</option>
                            </select>
                        </div>
                        <div class="col-sm-4">
                            <input type="text" class="form-control" name="scriptPath" id="scriptPath"
                                   placeholder="请输入脚本路径" style="display:none">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">执行策略:<font
                                color="red">*</font></label>
                        <div class="col-sm-4">
                            <select class="form-control" id="policyType" name="policyType">
                                <option value="00">随机</option>
                                <option value="01">分片</option>
                                <option value="02">权重</option>
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">请求参数:</label>
                        <div style="width:80%" class="col-sm-4"><input type="text" class="form-control"
                                                                       name="parameters"
                                                                       placeholder="请输入请求参数"
                                                                       maxlength="250"></div>
                    </div>
                    <div class="form-group">
                        <div class="col-sm-offset-3 col-sm-6">
                            <button type="submit" class="btn btn-primary" onclick="saveJobInfo()">保存</button>
                            <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>

<div class="modal fade" id="updateModal" tabindex="-1" role="dialog" aria-hidden="true">
    <div class="modal-dialog modal-lg">
        <div class="modal-content">
            <div class="modal-header">
                <h4 class="modal-title">修改任务</h4>
            </div>
            <div class="modal-body">
                <form class="form-horizontal form" role="form" id="updateJobInfo" action="/jobInfo/updateJob"
                      onsubmit="return false;">
                    <div class="form-group">
                        <label class="col-sm-2 control-label">组名:<font
                                color="red">*</font></label>
                        <div class="col-sm-4">
                            <input readonly type="text" class="form-control" name="jobGroup"
                                   placeholder="请输入组名"
                                   maxlength="32">
                        </div>
                        <label class="col-sm-2 control-label">任务名:<font
                                color="red">*</font></label>
                        <div class="col-sm-4"><input readonly type="text" class="form-control" name="jobName"
                                                     placeholder="请输入任务名"
                                                     maxlength="32"></div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">任务状态:<font
                                color="red">*</font></label>
                        <div class="col-sm-4">
                            <select class="form-control" id="status" name="jobStatus">
                                <option value="0">正常</option>
                                <option value="1">暂停</option>
                                <option value="2">删除</option>
                            </select>
                        </div>
                        <label class="col-sm-2 control-label">触发规则:<font
                                color="red">*</font></label>
                        <div class="col-sm-4"><input type="text" class="form-control" name="cronExpression"
                                                     placeholder="请输入触发规则"
                                                     maxlength="32"></div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">系统名:<font
                                color="red">*</font></label>
                        <div class="col-sm-4">
                            <select class="form-control" name="systemName">
                                <option th:each="system:${systemList}" th:value="${system.systemName}"
                                        th:text="${system.systemName}"></option>
                            </select>
                        </div>
                        <label class="col-sm-2 control-label">任务描述 :</label>
                        <div class="col-sm-4"><input type="text" class="form-control" name="jobDesc"
                                                     placeholder="请输入任务描述"
                                                     maxlength="32"></div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">serviceName:<font
                                color="red">*</font></label>
                        <div class="col-sm-4"><input type="text" class="form-control" name="service"
                                                     placeholder="请输入service"
                                                     maxlength="64"></div>
                        <label class="col-sm-2 control-label">methodName :<font
                                color="red">*</font></label>
                        <div class="col-sm-4"><input type="text" class="form-control" name="method"
                                                     placeholder="请输入method"
                                                     maxlength="64"></div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">任务依赖:</label>
                        <div style="width:80%" class="col-sm-4"><input type="text" class="form-control" name="depend"
                                                                       placeholder="请输入依赖的任务(任务组名_任务名)"
                                                                       maxlength="250"></div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">警告邮件:</label>
                        <div style="width:80%" class="col-sm-4"><input type="text" class="form-control"
                                                                       name="alarmEmail"
                                                                       placeholder="请输入警告邮件(多个用逗号隔开)"
                                                                       maxlength="250"></div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">并发控制:<font
                                color="red">*</font></label>
                        <div class="col-sm-4">
                            <select class="form-control" id="concurrentNum" name="concurrentNum"
                                    onchange="selectNum(this)">
                                <option value="0">无限</option>
                                <option value="1">有限</option>
                            </select>

                        </div>
                        <div class="col-sm-4">
                            <input type="text" class="form-control" name="concurrentCount" id="concurrentCount"
                                   placeholder="请输入具体数量" style="display:none">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">定时任务类型:<font
                                color="red">*</font></label>
                        <div class="col-sm-4">
                            <select class="form-control" id="taskType" name="taskType" onchange="putPath(this)">
                                <option value="0">代码</option>
                                <option value="1">shell脚本</option>
                            </select>
                        </div>
                        <div class="col-sm-4">
                            <input type="text" class="form-control" name="scriptPath" id="scriptPath"
                                   placeholder="请输入脚本路径" style="display:none">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">执行策略:<font
                                color="red">*</font></label>
                        <div class="col-sm-4">
                            <select class="form-control" id="policyType" name="policyType">
                                <option value="00">随机</option>
                                <option value="01">分片</option>
                                <option value="02">权重</option>
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">请求参数:</label>
                        <div style="width:80%" class="col-sm-4"><input type="text" class="form-control"
                                                                       name="parameters"
                                                                       placeholder="请输入请求参数"
                                                                       maxlength="250"></div>
                    </div>
                    <div class="form-group">
                        <div class="col-sm-offset-3 col-sm-6">
                            <button type="submit" class="btn btn-primary" onclick="updateJobInfo()">保存</button>
                            <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                            <input type="hidden" name="jobId" id="jobId">
                            <input type="hidden" name="version" id="version">
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
</body>

</html>
